<?php
$yii2appid = \common\config\Env::$yii2appid_home;
return [
    'id' => $yii2appid,
    'basePath' => dirname(__DIR__),
    'name' => "TITLE",
//    'homeUrl' => '/admin',
    'controllerNamespace' => 'home\controllers',
    'bootstrap' => [],
    'components' => [
        'request' => [
            'csrfParam' => YII_ENV . "_" . 'csrf-home-admin',
        ],
        'session' => [
            'name' => YII_ENV . "_" . 'session-home-admin',
            'useCookies' => true,
            'timeout' => 3600 * 24 * 30,
            'cookieParams' => [
//                'domain' => YII_ENV . "_" . $_SERVER['HTTP_HOST'],
//                'path' => '/',
                'httpOnly' => true,
                'lifetime' => 3600 * 24 * 30,
            ],
        ],
        'user' => [
            'class' => \common\rewrite\web\User::class,
            'identityClass' => \common\models\db\User::class,
            'loginUrl' => \common\config\Env::getUrls()['home_url'] . "/site/login" . \common\config\Env::$home_suffix,
            'enableAutoLogin' => true, // 就会使用cookie登录
            'autoRenewCookie' => true,
            'enableSession' => true,
            'identityCookie' => [
                'name' => YII_ENV . "_" . 'identity-home-admin',
                'domain' => YII_ENV . "_" . $_SERVER['HTTP_HOST'],
                'httpOnly' => true,
            ],
        ],
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => YII_ENV == 'dev' ? true : false,
            'suffix' => \common\config\Env::$home_suffix,
            'rules' => [
                'user/profile/index/<id:\d+>' => 'user/profile/index',
                'user/profile/box/<id:\d+>' => 'user/profile/box',
                'docu/<controller:\w+>/index/<per-page:\d+>-<page:\d+>' => 'docu/<controller>/index',
                'docu/<controller:\w+>/view/<uuid>' => 'docu/<controller>/view',
            ],
        ],
        'assetManager' => [
            'forceCopy' => YII_ENV == 'dev' ? true : false,
            'linkAssets' => YII_ENV == 'dev' ? true : false,
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'appinfo' => [
            'class' => \common\members\wodrow\components\yii2app\Appinfo::class,
            'name' => $yii2appid,
        ],
    ],
    'modules' => [
        'redactor' => 'yii\redactor\RedactorModule',
        'test' => [
            'class' => \home\modules\test\Test::class,
        ],
        'docu' => [ // 文档 新闻，文章等
            'class' => \home\modules\docu\Docu::class,
        ],
        'user' => [
            'class' => \home\modules\user\User::class,
        ],
    ],
    'as access' => [
        'class' => \yii\filters\AccessControl::class,
        'except' => [
            'site/*',
            'user/profile/index',
            'user/profile/box',
            'docu/*',
            'gii/*',
            'debug/*',
        ],
        'rules' => [
            [
                'allow' => true,
                'roles' => ['@'],
            ],
        ],
    ],
    'params' => [],
];
